package com.parktech.sun.web.controller;

import com.parktech.sun.domain.model.aboutus.Cooperation;
import com.parktech.sun.domain.model.notice.Notice;
import com.parktech.sun.domain.repository.Page;
import com.parktech.sun.domain.service.aboutus.CooperationService;
import com.parktech.sun.domain.service.industryinfo.IndustryInfoService;
import com.parktech.sun.domain.service.industryservice.IndustryServiceService;
import com.parktech.sun.domain.service.notice.NoticeService;
import com.parktech.sun.domain.service.specialtopic.SpecialTopicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ModelAttribute;

import java.util.List;

/**
 * User: Think
 * Date: 11-1-18
 * Time: 上午1:01
 */
public class BaseViewController {

    @Autowired
    private IndustryServiceService industryServiceService;

    @Autowired
    private IndustryInfoService industryInfoService;

    @Autowired
    private NoticeService noticeService;

    @Autowired
    private CooperationService cooperationService;

    @Autowired
    private SpecialTopicService specialTopicService;

    @ModelAttribute("industryServiceList")
    public List populateIndustryServiceList() {
        return industryServiceService.search(null, new Page(1000, 1)).getResult();
    }

    @ModelAttribute("industryInfoCategoryList")
    public List populateIndustryInfoCategoryList() {
        return industryInfoService.searchCategory(null, new Page(1000, 1)).getResult();
    }

    @ModelAttribute("specialTopicCategoryList")
    public List populateSpecialTopicCategoryList() {
        return specialTopicService.searchCategory(null, new Page(1000, 1)).getResult();
    }

    @ModelAttribute("top5Notice")
    public List<Notice> populateTop5Notice() {
        return noticeService.getTopN(5);
    }

    @ModelAttribute("cooperationList")
    public List populateCooperationList() {
        return cooperationService.listAll();
    }
}
